﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeoVision.Addin.Helpers;
using GeoVision.Addin.Core.Settings;

namespace GeoVision.Addin.UI.Settings
{
    public partial class SettingsForm : Form
    {
        List<CultureSettins> langList;
        public SettingsForm()
        {
            LocalizationHelper.SetCulture();
            InitializeComponent();
            langList = new List<CultureSettins>
            {
                new  CultureSettins{Name="Turkish",CultureName=CultureShortName.TR},
                new  CultureSettins{Name="English",CultureName=CultureShortName.ENG}

            };

        }

        private void btnSetLang_Click(object sender, EventArgs e)
        {
            if (cmbLanguage.SelectedItem != null)
            {
                CultureSettins lang = (CultureSettins)cmbLanguage.SelectedItem;
                LocalizationHelper.SetCulture(lang);
                this.Close();
            }
        }

        private void SettingsForm_Load(object sender, EventArgs e)
        {
            string valCurrent = RegistryHelper.GetCurrentLanguageString();
            cmbLanguage.DataSource = langList;
            cmbLanguage.DisplayMember = "Name";
            cmbLanguage.ValueMember = "CultureName";
            if (!string.IsNullOrEmpty(valCurrent))
            {
                if (valCurrent == CultureShortName.TR)
                {
                    cmbLanguage.SelectedIndex = 0;
                }
                else if (valCurrent == CultureShortName.ENG)
                {
                    cmbLanguage.SelectedIndex = 1;
                }
            }
            else
            {
                cmbLanguage.SelectedIndex = 1;
            }
        }
    }
}
